package agents;

import ai1.Enviroment;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author orcas
 */
public abstract class Agent {

    private String name;
    private int row;
    private int col;
    private String orientation;

    public Agent(String name, int row, int col, String orientation) {
        this.name = name;
        this.row = row;
        this.col = col;
        this.orientation = orientation;
    }

    public abstract String getMove(Enviroment env);

    public String getName() {
        return name;
    }

    public int getRow() {
        return row;
    }

    public int getCol() {
        return col;
    }

    public String getOrientation() {
        return orientation;
    }

    public int[] getForward() {
        int newCell[] = {row, col};
        if (orientation.compareTo("North") == 0) {
            newCell[0]--;
        } else if (orientation.compareTo("East") == 0) {
            newCell[1]++;
        } else if (orientation.compareTo("West") == 0) {
            newCell[1]--;
        } else if (orientation.compareTo("South") == 0) {
            newCell[0]++;
        }
        return newCell;
    }

    public void updatePosition(String move) {
        if (move.compareTo("RIGHT") == 0) {
            if (orientation.compareTo("North") == 0) {
                orientation = "East";
            } else if (orientation.compareTo("East") == 0) {
                orientation = "South";
            } else if (orientation.compareTo("West") == 0) {
                orientation = "North";
            } else if (orientation.compareTo("South") == 0) {
                orientation = "West";
            }
        } else if (move.compareTo("LEFT") == 0) {
            if (orientation.compareTo("North") == 0) {
                orientation = "West";
            } else if (orientation.compareTo("East") == 0) {
                orientation = "North";
            } else if (orientation.compareTo("West") == 0) {
                orientation = "South";
            } else if (orientation.compareTo("South") == 0) {
                orientation = "East";
            }
        } else if (move.equals("FWD")) {
            int newCell[] = getForward();
            row = newCell[0];
            col = newCell[1];
        }
        else 
            System.out.println("### o rly");
    }
}
